// run: $exec < input
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>

int const len = 909526;

int main()
{
	std::ios::sync_with_stdio(false);
	std::srand(std::time(0));
	std::string s;
	int T; std::cin >> T;
	int count = 0;
	while (T--) {
		std::cin >> s;
		int n = s.size();
		int t = s[n - 1] - '0';
		if (n > len + 1) {
			if (count == 1 || count == 2)
				std::cout << 1 << '\n';
			else
				std::cout << 0 << '\n';
			count++;
		} else {
			std::cout << (t & 1) << '\n';
		}
	}
}

